package mao.leetcode.array.leetcode55;

public class Solution {

    public boolean canJump(int[] nums) {
        int len = nums.length;
        if (len<=1) return true;
        boolean[] canReach = new boolean[nums.length];
        canReach[0]=true;
        for (int i = 1; i < len; i++) {
            for (int j = i-1; j >= 0; j--) {
                if (canReach[j] && nums[j] >= i-j){
                    canReach[i] = true;
                    break;
                }
            }
        }
        return canReach[len-1];
    }

    public static void main(String[] args) {
        boolean[] canRearch = new boolean[3]; //初始化是false
        for (boolean rearch : canRearch) {
            System.out.println(rearch);
        }
    }
}
